@extends('admin.base')
@section('title', '心愿列表')
@section('content')
    <div class="layui-card">
        <fieldset class="layui-elem-field">
            <div class="layui-field-box">
                <a class="layui-btn-sm" href="{{url('admin/home')}}">首页</a>&raquo;
                <span class="layui-btn-sm" href="{{url('admin/wish/index')}}">心愿列表</span>
            </div>
        </fieldset>
        <div class="layui-card-header">
            <div>
                <span class="pull-left">
                  <div class="layui-form">
                    <div class="layui-form-item">
                      {{--<div class="layui-inline">--}}
                        {{--<label class="layui-form-label">关键字</label>--}}
                        {{--<div class="layui-input-inline">--}}
                            {{--<input type="text" class="layui-input" id="sub_keywords" name="keywords"--}}
                                   {{--value="{{ isset($request->keywords) ? $request->keywords : '' }}"--}}
                                   {{--placeholder="请输入账户">--}}
                        {{--</div>--}}
                      {{--</div>--}}
                        <div class="layui-inline">
                        <label class="layui-form-label">状态</label>
                        <div class="layui-input-inline">
                            <select name="sh_state" lay-verify="required">
                                <option value="0">请选择</option>
                                <option value="1" @if($request->state == 1) selected @endif>待发货</option>
                                <option value="2" @if($request->state == 2) selected @endif>待收货</option>
                                <option value="3" @if($request->state == 3) selected @endif>已完成</option>
                            </select>
                        </div>
                      </div>
                        <div class="layui-inline">
                        <label class="layui-form-label">时间</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" class="jeinput" id="test11" placeholder="创建时间(年月日~年月日)"
                                   name="month" value="{{ isset($request->month) ? $request->month : '' }}" readonly>
                        </div>
                        </div>
                    </div>
                  </div>
                </span>
                <div class="layui-input-inline">
                    <button class="layui-btn" lay-submit lay-filter="selectsub" style="margin-top:-10px">搜索</button>
                </div>
            </div>
        </div>

        <div class="layui-card-body">
            <style>
                table tr td.tc, table tr th.tc {
                    text-align: center;
                    cursor: default;
                }
            </style>
            <table class="layui-table" lay-even lay-size="">
                <colgroup>
                    <col width="">
                    <col width="">
                    <col width="">
                    <col width="">
                </colgroup>
                <thead>
                <tr>
                    <th class="tc">ID</th>
                    <th class="tc">账户</th>
                    <th class="tc">商品名</th>
                    <th class="tc">能量值</th>
                    <th class="tc">进行中能量</th>
                    <th class="tc">收货人</th>
                    <th class="tc">收货人联系方式</th>
                    <th class="tc">收货地址</th>
                    <th class="tc">快递公司</th>
                    <th class="tc">快递单号</th>
                    <th class="tc">状态</th>
                    <th class="tc">下单时间</th>
                    <th class="tc">发货时间</th>
                    <th class="tc">操作</th>
                </tr>
                <tbody>
                @if($list->isEmpty())
                    <tr>
                        <td colspan="14" class="tc">暂无数据</td>
                    </tr>
                @else
                    @foreach ($list as $v)
                        <tr>
                            <td class="tc">{{$v->id}}</td>
                            <td class="tc">{{ $v->user }}</td>
                            <td class="tc">{{ $v->gname }}</td>
                            <td class="tc">{{ $v->total }}</td>
                            <td class="tc">{{ $v->in_total }}</td>
                            <td class="tc">{{ $v->linkname }}</td>
                            <td class="tc">{{ $v->linktel }}</td>
                            <td class="tc">{{ $v->address }}</td>
                            <td class="tc">{{ $v->express_com }}</td>
                            <td class="tc">{{ $v->express_num }}</td>
                            <td class="tc">
                                @if($v->state == 1)待发货
                                @elseif($v->state == 2)待收货
                                @elseif($v->state == 3)已完成
                                @endif
                            </td>
                            <td class="tc">{{ $v->created_at }}</td>
                            <td class="tc">{{ $v->send_time }}</td>
                            <td class="tc">
                                <div class="layui-btn-group">
                                    @if($v->state == 1)
                                        <button class="layui-btn layui-btn-sm"
                                                onclick="active('{{url('admin/wish/send_ok?page='.$request->page.'&state='.$request->state.'')}}','{{$v->id}}','请输入快递信息');">发货
                                        </button>
                                    @elseif($v->state == 2)
                                        <button class="layui-btn layui-btn-sm layui-btn-disabled">无
                                        </button>
                                    @elseif($v->state == 3)
                                        <button class="layui-btn layui-btn-sm layui-btn-disabled">无
                                        </button>
                                    @endif

                                </div>
                            </td>
                        </tr>
                    @endforeach
                @endif
                </tbody>
                </thead>
            </table>
            <!-- 分页 -->
            <div class="sabrosus">{{ $list->appends(['keywords'=>$request->keywords,'state'=>$request->state,'month'=>$request->month])->links() }}</div>
        <!-- {{$list->total()}} -->
        </div>

    </div>
@endsection
@section('js')
    <script>
        layui.use('form', function () {
            var form = layui.form;

            //搜索
            form.on('submit(selectsub)', function (data) {
                let keywords = $('#sub_keywords').val();//关键字
                let sh_state = $("select[name=sh_state]").val();
                var month = $("input[name=month]").val();
                location.href = "{{url('admin/wish/index')}}" + "?keywords=" + keywords + "&state=" + sh_state+'&month='+month;
                return false;
            });
        });

        function auth_ok(url, id, state) {
            layer.confirm('确认通过？', {
                btn: ['确定', '取消']//按钮
            }, function (index) {

                layer.close(index);
                //此处请求后台程序，下方是成功后的前台处理……
                $.ajax({
                    url: url,
                    type: 'post',
                    async: false,
                    data: {'id': id, 'state': state, _token: "{{csrf_token()}}"},
                    success: function (data) {
                        layer.msg(data.msg);
                        location.href = location.href;
                    },
                    error: function () {

                    }
                })
            });
        }
    </script>
@endsection